<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/

// Define a destination
$targetFolder = 'rhb/assets/uploads/videos'; // Relative to the root


if (!empty($_FILES)) {	
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
	
	
	
	// Validate the file type
	$fileTypes = array('jpg','mp4','flv'); // File extensions
	$fileParts = pathinfo($_FILES['Filedata']['name']);
	
	$targetFileName = "video_".date("ymdhis").".".$fileParts['extension'];
	$targetFile = rtrim($targetPath,'/') . '/' . $targetFileName;
	
	if (in_array(strtolower($fileParts['extension']),$fileTypes)) {
		move_uploaded_file($tempFile,$targetFile);
		echo '1';
	} else {
		echo 'Invalid file type.';
	}
}
else
{
	echo "could not process file";
}
?>